Array.prototype.includes = function (item) {
    for (var i = 0; i < this.length; i++)
        if (this[i] === item)
            return true;
    return false;
}

var Trie = (function () {
    function Trie() {
        this.list = new Array();
    }

    Trie.prototype.insert = function (word) {
        if (typeof (word) == 'string')
            if (!this.list.includes(word))
                this.list.push(word);
    }

    Trie.prototype.contains = function (word) {
        for (var i = 0; i < this.list.length; i++) {
            if (typeof (this.list[i]) === 'string')
                if (this.list[i].startsWith(word))
                    return true;
        }

        return false;
    }

    Trie.prototype.find = function (word) {
        var res = [];

        for (var i = 0; i < this.list.length; i++) {
            if (this.list[i].startsWith(word))
                res.push(this.list[i]);
        }

        return res.sort();
    }

    return Trie;
})();